from pyudev import Context, Monitor

class USBHotPlugMonitor:
    def __init__(self):
        self.context = Context()
        self.monitor = Monitor.from_netlink(self.context)
        self.monitor.filter_by(subsystem='usb')

    def start(self):
        """开始监听"""
        for device in iter(self.monitor.poll, None):
            print(f"Device {device.action}: {device.device_path}")